package com.starinside.wp.repository;

import com.starinside.wp.domain.Feeds;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Describle This Class Is
 * @Author ZengMin
 * @Date 2018/11/9 10:54
 * @Company Matt
 */
@Repository
public interface FeedsRepository extends JpaRepository<Feeds,String> {

    @Query(value = "SELECT f from Feeds f where f.place in (?2) and (f.childrenId is not null and f.childrenId in (?1))  ORDER BY f.created DESC")
    List<Feeds> findAllByChildrenIdsAndAreaIdIn(List<String> childrensId, List<String> areaId, Pageable pageable);

    @Query(value = "select count(1) from Feeds f where f.place in (?2) and (f.childrenId is not null and f.childrenId in (?1))")
    long findAllByChildrenIdsAndAreaIdCount(List<String> childrensId, List<String> areaId);

}
